package com.qf.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;

public class ShiroTest {
    public static void main(String[] args) {
        Factory<SecurityManager> factory = new IniSecurityManagerFactory();
        SecurityManager security = factory.getInstance();
        SecurityUtils.setSecurityManager(security);
        Subject subject = SecurityUtils.getSubject();


        System.out.println( subject.isAuthenticated());
        System.out.println(subject.getPrincipal());


        UsernamePasswordToken token = new UsernamePasswordToken("zhangsan","123");
        subject.login(token);

        System.out.println( subject.isAuthenticated());

    }
}
